package com.blue.rpc.core.registry;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;

public class ServiceWatcher implements Watcher
{
	private ZooKeeperDiscovery discovery;

	public ServiceWatcher(ZooKeeperDiscovery discovery)
	{
		this.discovery = discovery;
	}

	@Override
	public void process(WatchedEvent event)
	{
		System.out.println(event);
		if (event.getType() == Watcher.Event.EventType.NodeChildrenChanged)
		{
			discovery.updateService();
		}
	}
	
}
